<template>
  <view class="door">
    <view class="picture-box">
      <view class="picture-information">
        <view class="apartment-title"> 夸父公寓 </view>
      <view class="apartment-period">
        {{ unit }}单元{{ floot }} 有效期：{{ validity }}
      </view>
        <!-- <view
          class="picture"
          @click="unlockingClick"
          :class="btnText == '点击开锁' ? '' : 'open'"
        >
          <view class="lock"> </view>
          <text class="explain">
            {{ btnText }}
          </text>
        </view> -->
        <!-- <view class="information">
          <view class="information-item">
            <view class="level"></view> {{ level }}
          </view>
          <view class="information-item">
            <view class="wifi"></view> {{ wifi }}
          </view>
          <view class="information-item">
            <view class="authorization"></view> {{ authorization }}
          </view>
        </view> -->
      </view>
    </view>
    <view class="room-btn apartment">
      
      <button class="btn" form-type="submit" @click="getTemporaryPasswordData">
        获取临时密码
      </button>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { getTemporaryPasswordApi } from "@/package_property/pages/api/home";
import { onLoad } from "@dcloudio/uni-app";
const floot = ref("");
const unit = ref("");
const validity = ref("2024/06/01-2025/06/01");
const btnText = ref("暂无权限");
const level = ref("90%");
const wifi = ref("强");
const authorization = ref("已授权");
function unlockingClick() {
  // if (btnText.value == "点击开锁") {
  //   btnText.value = "点击锁上";
  // } else {
  //   btnText.value = "点击开锁";
  // }
}
function getTemporaryPasswordData() {
  getTemporaryPasswordApi(floot.value).then((res) => {
    console.log(res);
    if (res.code == 200) {
      uni.showToast({
        title: "已发送短信，注意查看",
        duration: 2000,
        icon:"none"
      });
    } else {
      uni.showToast({
        title: res.msg,
        icon:"none",
        duration: 2000,
      });
    }
  });
}
onLoad((option) => {
  console.log(option);
  let item = JSON.parse(option.item);
  console.log(item);
  floot.value = item.accountNumber;
  unit.value = item.unit;
  validity.value = item.leaseDuration;
});
</script>

<style lang="less" scoped>
@import url(./style/door.less);
</style>